package GameLogic
{
	import fl.containers.ScrollPane;
	import fl.controls.UIScrollBar;
	import flash.display.Shape;
	import flash.display.Sprite;
	import flash.events.Event;
	import flash.events.MouseEvent;
	import flash.geom.Rectangle;
	import flash.text.TextField;
	import flash.ui.Mouse;
	import flash.ui.MouseCursor;
	public class ApiCheck extends Sprite
	{
		private var w:int = 240;
		private var h:int = 0;
		private var pos:int = 0;
		private var close:TextField;
	
		public function ApiCheck(_name:String)
		{
			var clr:int = 0x3E3A3A;
			var w:int = 100;
			var h:int = 22;
			var Name:TextField = new TextField();
			Name.textColor = 0xffffff;
			Name.text = _name;
			Name.width = w;
			Name.height = h;
			Name.textColor = 0xffffff;
			Name.selectable = false;
			var shape:Shape =  new Shape();
			shape.graphics.beginFill(clr, 0.9);
			shape.graphics.drawRect(0, 0, 240, h);
			addChild(shape);
			addChild(Name);
			close = new TextField();
			close.text = "X";
			close.width = 13;
            close.height = 16;
			close.textColor = 0x000000;
			close.background = true;
			close.backgroundColor = 0xDBE0DA;
			close.border = true;
			close.borderColor = 0xffffff;
			close.x = 223;
			close.y = 2;
			close.addEventListener(MouseEvent.CLICK, function(e:Event):void
			{
				visible = false;
				if (!Game.LuaEdit.ApiChoise.selected)
				   Game.LuaEdit.input.text = "";
			});
			close.addEventListener(MouseEvent.MOUSE_OVER, function(e:Event):void
			{
				Mouse.cursor = MouseCursor.BUTTON;
			});
			close.addEventListener(MouseEvent.MOUSE_OUT, function(e:Event):void
			{
				Mouse.cursor = MouseCursor.AUTO;
			});
			addChild(close);
		}
		
		public function Add(_name:String, _note:String, _remark:String,_s:Boolean=false):void
		{
			var item:ApiItem = new ApiItem(_name, _note,_remark,_s);
			AddItem(item);
		}
		
		public function AddItem(_item:ApiItem):void
		{
			pos += 22;
			_item.y = pos;
			h += 22;
			addChild(_item);
			Game.LuaScriptApiSt[_item.apiName] = "--[[\n\t"+ _item.Remark+"\n]]--";
		}
		
		public function BorderBg():void
		{
			var bg:Shape = new Shape();
			bg.graphics.beginFill(0xffffff, 1);
			bg.graphics.drawRect(0, 0, 241, (h + 23));
			addChild(bg);
			bg.x = -1;
			bg.y = -1;
			this.setChildIndex(bg, 0);
		}
	}
}